﻿using Communergy.Common;
using Communergy.Repository;

namespace CommunergyUploader
{
    public class CommunergyClientFactory
    {
        //TODO - find and replaces references, move to proper repository
        public static IMeterRepository GetLocalMeterStore()
        {
            string connectionString = ConfigurationHelper.SqliteConnectionString(ConfigurationHelper.SQLLitePath);
            var sqlLiteFactory = new SQLiteRepositoryFactory();
            var localMeterStore = sqlLiteFactory.CreateMeterRepository(sqlLiteFactory.CreateUnitOfWork());
            return localMeterStore;
        }

        public static IMeterRepository GetRemoteMeterStore()
        {
            var localMeterStore = new CommunergyUpload();
            return localMeterStore;
        }


        //public static IRealtimeRepository GetLocalRealtimeCache()
        //{
        //    string connectionString = ConfigurationHelper.SqliteConnectionString(ConfigurationHelper.SQLLitePath);
        //    var db = new CommunergySQLiteEntities(connectionString);
        //    SQLiteRealtimeRepository localCache = new SQLiteRealtimeRepository(db); 
        //    return localCache;
        //}

        public static IHistoricRepository GetLocalHistoricCache()
        {
            string connectionString = ConfigurationHelper.SqliteConnectionString(ConfigurationHelper.SQLLitePath);
            var localCache = new SQLiteHistoricRepository(connectionString);
            return localCache;
        }


        public static IRealtimeRepository GetUploadRealtimeTarget()
        {

            var uploadTarget = new UploadWeatherWCFAndCommunergy();
            return uploadTarget;
        }

        public static IHistoricRepository GetUploadHistoricTarget()
        {

            var uploadTarget = new UploadWeatherWCFAndCommunergy();
            return uploadTarget;
        }
    }
}
